#include <iostream>

using namespace std;
//分别利用普通写法和多态技术，设计实现两个操作数进行运算的计算器类
//多态的优点：
//1、代码组织结构清晰
//2、可读性强
//3、利于前期和后期的扩展以及维护


//普通写法
class Calculator {
public:
    int num1;
    int num2;

    int getResult(string o) {
        if (o == "+") {
            return num1 + num2;
        } else if (o == "-") {
            return num1 - num2;
        } else if (o == "*") {
            return num1 * num2;
        }
    }
    //如果要提供新的运算，需要修改源码
};

void test1() {
    Calculator calculator;
    calculator.num1 = 10;
    calculator.num2 = 20;
    cout << calculator.num1 << "+" << calculator.num2 << "=" << calculator.getResult("+") << endl;
    cout << calculator.num1 << "-" << calculator.num2 << "=" << calculator.getResult("-") << endl;
    cout << calculator.num1 << "*" << calculator.num2 << "=" << calculator.getResult("*") << endl;
}

int main() {
    test1();
    return 0;
}